<template>
	<view class="address">
		<view class="addresslist">
			<view class="address_item" v-for="(item,index) in addressList" :key='item.id'>
				<label class="radio">
					<radio @click="change(index)" :checked="radioShow === index" />
				</label>
				<view class="info">
					<view class="top">
						<text class="name">{{item.name}}</text>
						<text class="phone">{{item.phone}}</text>
					</view>
					<view class="msg">
						<text>{{item.address}}</text>
					</view>
				</view>
				<view class="delete" @click="deleteAddress(item.id)">
					删除
				</view>
			</view>
		</view>
		<view class="noaddress">
			<view class="add_text" @click="toAdd">
				新增收货地址
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				radioShow: 0,
				addressList: [{
						'id': 1,
						'name': 'YS',
						'phone': '15311110000',
						'address': '江苏省 盐城市 高新区'
					},
					{
						'id': 2,
						'name': 'YS-1',
						'phone': '15311110001',
						'address': '江苏省 盐城市 艾欧尼亚'
					},
					{
						'id': 3,
						'name': 'YS-2',
						'phone': '15311110002',
						'address': '江苏省 盐城市 祖安'
					}
				]
			}
		},
		onLoad() {

		},
		methods: {
			change(i) {
				this.radioShow = i
			},
			deleteAddress(i){
				
			},
			toAdd(){
				uni.navigateTo({
					url:'/pages/addAddress/index'
				})
			}
		}
	}
</script>

<style lang="scss">
	.address {
		padding-top: 50rpx;

		.addresslist {
			.address_item {
				position: relative;
				display: flex;
				align-items: center;
				background-color: #FFFFFF;
				width: 80%;
				padding: 5%;
				margin: 0 auto;
				margin-bottom: 30rpx;
				border-radius: 10rpx;

				.info {
					margin-left: 20rpx;

					.top {
						font-size: 16px;

						.phone {
							font-size: 14px;
							color: #777777;
							margin-left: 10rpx;
						}
					}
				}

				.msg {
					margin-top: 10rpx;
				}

				.delete {
					position: absolute;
					right: 10px;
					top: 55px;
					font-size: 12px;
					color: #999;
				}
			}
		}

		.noaddress {
			padding-top: 50rpx;

			.add_text {
				border: 1px solid #FF3C29;
				color: #FF3C29;
				text-align: center;
				height: 40px;
				line-height: 40px;
				width: 50%;
				margin: 0 auto;
				border-radius: 5px;
			}
		}
	}
</style>
